package com.wd.demo1.config;

import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.NlsContexts.ConfigurableName;
import javax.swing.JComponent;
import org.jetbrains.annotations.Nullable;

/**
 * @author Administrator
 * @date 2025-11-02 15:19
 */
public class DemoConfig implements Configurable {

	private DemoConfigUI demoConfigUI;

	@Override
	public @ConfigurableName String getDisplayName() {
		return "Demo Config";
	}

	@Override
	public @Nullable JComponent createComponent() {
		if (demoConfigUI == null) {
			demoConfigUI = new DemoConfigUI();
		}
		return demoConfigUI.createComponent();
	}

	@Override
	public boolean isModified() {
		if (demoConfigUI == null) {
			return false;
		}
		return demoConfigUI.isModified();
	}

	@Override
	public void apply() throws ConfigurationException {
		if (demoConfigUI == null) {
			return;
		}
		demoConfigUI.apply();
	}

	@Override
	public void reset() {
		if (demoConfigUI == null) {
			return;
		}
		demoConfigUI.reset();
	}

	@Override
	public void disposeUIResources() {
		demoConfigUI = null;
	}
}
